package day18_PokerGame.PokerGame;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeSet;

//斗地主初始化纸牌、洗牌、发牌、展示牌并排序
public class PokerGame {
    static ArrayList<Integer> poker=new ArrayList<>();
    static HashMap<Integer,String> map=new HashMap<>();
    static{
        map.put(54,"大王");
        map.put(53,"小王");
        char[] color=new char[]{'♠','♥','♣','♦'};
        String[] number=new String[]{"3","4","5","6","7","8","9","10","J","Q","K","A","2"};
        int num=1;
        for(int i=0;i<number.length;i++){
            for(int j=0;j<color.length;j++){
                map.put(num++,color[j]+number[i]);
            }
        }
        for(int i=1;i<=54;i++){
            poker.add(i);
        }
    }
    public PokerGame() {
        Collections.shuffle(poker);
        TreeSet<Integer> lord=new TreeSet<>();
        TreeSet<Integer> player1=new TreeSet<>();
        TreeSet<Integer> player2=new TreeSet<>();
        TreeSet<Integer> player3=new TreeSet<>();
        for(int i=0;i<3;i++){
            lord.add(poker.get(i));
        }
        for(int i=3;i<54;i++){
            if(i%3==0) player1.add(poker.get(i));
            else if(i%3==1) player2.add(poker.get(i));
            else player3.add(poker.get(i));
        }
        lookPoker(lord);
        lookPoker(player1);
        lookPoker(player2);
        lookPoker(player3);
    }
    public void lookPoker(TreeSet<Integer> ts){
        for (Integer t : ts) {
            System.out.print(map.get(t)+" ");
        }
        System.out.println();
    }
}
